package com.ruoyi.jobSys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jobSys.domain.Joblist;
import com.ruoyi.jobSys.service.IJoblistService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 岗位管理Controller
 * 
 * @author binbin
 * @date 2024-05-19
 */
@RestController
@RequestMapping("/jobSys/joblist")
public class JoblistController extends BaseController
{
    @Autowired
    private IJoblistService joblistService;

    /**
     * 查询岗位管理列表
     */
    @PreAuthorize("@ss.hasPermi('jobSys:joblist:list')")
    @GetMapping("/list")
    public TableDataInfo list(Joblist joblist)
    {
        startPage();
        List<Joblist> list = joblistService.selectJoblistList(joblist);
        return getDataTable(list);
    }

    /**
     * 导出岗位管理列表
     */
    @PreAuthorize("@ss.hasPermi('jobSys:joblist:export')")
    @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Joblist joblist)
    {
        List<Joblist> list = joblistService.selectJoblistList(joblist);
        ExcelUtil<Joblist> util = new ExcelUtil<Joblist>(Joblist.class);
        util.exportExcel(response, list, "岗位管理数据");
    }

    /**
     * 获取岗位管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('jobSys:joblist:query')")
    @GetMapping(value = "/{jobId}")
    public AjaxResult getInfo(@PathVariable("jobId") Long jobId)
    {
        return success(joblistService.selectJoblistByJobId(jobId));
    }

    /**
     * 新增岗位管理
     */
    @PreAuthorize("@ss.hasPermi('jobSys:joblist:add')")
    @Log(title = "岗位管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Joblist joblist)
    {
        return toAjax(joblistService.insertJoblist(joblist));
    }

    /**
     * 修改岗位管理
     */
    @PreAuthorize("@ss.hasPermi('jobSys:joblist:edit')")
    @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Joblist joblist)
    {
        return toAjax(joblistService.updateJoblist(joblist));
    }

    /**
     * 删除岗位管理
     */
    @PreAuthorize("@ss.hasPermi('jobSys:joblist:remove')")
    @Log(title = "岗位管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jobIds}")
    public AjaxResult remove(@PathVariable Long[] jobIds)
    {
        return toAjax(joblistService.deleteJoblistByJobIds(jobIds));
    }
}
